package com.example.nonggo.bean;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import okhttp3.MediaType;
import okhttp3.RequestBody;

public class SubmitQuestionBody {
    //   {
//    "applicationName": "nong",
//    "title": "蝴蝶兰适合什么样的土壤？是普通的园土，还是需要特殊的基质？",
//    "phone": "15626446758",
//    "showImgList": [],
//    "showVideoList": [],
//    "collectionTime": 1741410543421,
//    "recentMedication": "",
//    "occurrenceArea": "",
//    "openType": 0,
//    "recentWeather": "",
//    "assignmentDeptId": ""
//}
    private String applicationName;
    private String title;
    private String phone;

    private List<String> showImgList;
    private List<String> showVideoList;
    private long collectionTime;
    private String recentMedication;
    private String occurrenceArea;
    private int openType;
    private String recentWeather;
    private String assignmentDeptId;

    public SubmitQuestionBody(String title, String phone) {
        this.title = title;
        this.phone = phone;
        this.collectionTime = System.currentTimeMillis() / 1000;
        this.openType = 0;
        this.assignmentDeptId = "";
        this.applicationName = "nong";
        this.recentMedication = "";
        this.occurrenceArea = "";
        this.recentWeather = "";
//        this.showImgList = new ArrayList<>();
//        this.showVideoList = new ArrayList<>();
    }
    public RequestBody toRequestBody(){
        JSONObject j = new JSONObject();
        try {
            j.put("applicationName", applicationName);
            j.put("title", title);
            j.put("phone", phone);
            j.put("showImgList", showImgList);
            j.put("showVideoList", showVideoList);
            j.put("collectionTime", collectionTime);
            j.put("recentMedication", recentMedication);
            j.put("occurrenceArea", occurrenceArea);
            j.put("openType", openType);
            j.put("recentWeather", recentWeather);
            j.put("assignmentDeptId", assignmentDeptId);
        } catch (JSONException ignore) {
        }
        return RequestBody.create(MediaType.parse("application/json"), j.toString());
    }
}
